package app.lazygamer;


import android.app.Activity;
import android.content.Intent;

import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;



import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import android.widget.ImageView;



public class Infinity_Browser extends Activity  {
	WebView web1;
	WebSettings webSettings;

	Resources res;
	String url;
	Intent intent;
	
	ImageView back;
   	ImageView front;
   	ImageView refresh;
   	ImageView sett;
   	
   	ImageView webbar;
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.infinity_browser);
        Bundle extras = getIntent().getExtras();
        url = extras.getString("urls");
       
      
       
     
        
         back = (ImageView) findViewById(R.id.backward);
       	 front = (ImageView)findViewById(R.id.forward);
       	 refresh = (ImageView) findViewById(R.id.refresh);
       	 sett = (ImageView) findViewById(R.id.sett);
         web1 = (WebView) findViewById(R.id.browser);
        
         web1.getSettings().setJavaScriptEnabled(true);
         web1.loadUrl(url);
   	 	 web1.setWebViewClient(new WebViewClient());
   	 	 web1.getSettings().setLoadWithOverviewMode(true);
         web1.getSettings().setUseWideViewPort(true);
        
   	 webSettings = web1.getSettings();
   	 webSettings.setSavePassword(true);
   	 webSettings.setSaveFormData(true);
   	 
   	 

   
   	

	
   	back.setOnClickListener(new OnClickListener(){

		@Override
		public void onClick(View arg0) {
			if(web1.canGoBack() == true) {
				web1.goBack();
			}
		} 
    });
   	front.setOnClickListener(new OnClickListener(){

		@Override
		public void onClick(View arg0) {
			if(web1.canGoForward() == true) {
				web1.goForward();
			}
		} 
    });
   	refresh.setOnClickListener(new OnClickListener(){

		@Override
		public void onClick(View arg0) {
				web1.reload();
		} 
    });
	
	sett.setOnClickListener(new OnClickListener(){

		@Override
		public void onClick(View arg0) {
			 intent = new Intent(Infinity_Browser.this, Browser_Set.class);
			startActivity(intent);	
		} 
    });
    }
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
	    MenuInflater inflater = getMenuInflater();
	    inflater.inflate(R.menu.browse_menu, menu);
	    return true;
	}
	public boolean onOptionsItemSelected(MenuItem item) {
	  
		if (item.getItemId()==R.id.Settings) {
			intent = new Intent(this, Browser_Set.class);
			startActivity(intent);
			return(true);
		}
			return false;
	    	
	       
	    
	
	}
	 public int getScreenOrientation() {


		  // Query what the orientation currently really is.
		  if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)                {
		      // The following message is only displayed once.
		       return 1; // Portrait Mode
		   
		  }else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
		      // The following message is only displayed once.
		       return 2;   // Landscape mode
		  }
		  return 0;
		 }
}